
#include <windows.h>   // Standard Header For Most Programs
#include "wintoolkit.h"

#include "render.h"



#include <boost/shared_ptr.hpp>


//#include <boost/numeric/ublas/matrix.hpp>
//#include <boost/numeric/ublas/vector.hpp>
//namespace bnu = boost::numeric::ublas;


render::Device device;




void display ( void )   
{
    //render::Something something;
    //render::draw(something);
}


void reshape ( int width , int height )
{
    render::Viewport vp;
    render::set(vp, device);


    //render::Perspective ps;
    //render::set(ps, device);


}


void keyboard ( unsigned char key, int x, int y )  
{
    switch ( key ) 
    {
    case 27:      
        exit ( 0 );  
        break;       
    default:       
    break;
    }
}
//void arrow_keys ( int a_keys, int x, int y ) 
//{
// switch ( a_keys ) {
//case GLUT_KEY_UP:    
// glutFullScreen ( );
// break;
//case GLUT_KEY_DOWN:               
// glutReshapeWindow ( 500, 500 ); 
//default:
// break;
// }
//}




void main ( int argc, char** argv )   // Create Main Function For Bringing It All Together
{
    
    wintoolkit::set<wintoolkit::GLUTWindows>(argc, argv);
    wintoolkit::set<wintoolkit::DisplayCallBack>( display );
    wintoolkit::set<wintoolkit::ReshapeCallBack>( reshape );
    wintoolkit::set<wintoolkit::KeyboardCallBack>( keyboard ); 


    render::set(device); 


    render::GPUProgram prog;
    render::set(prog, device);


    glutMainLoop( );


    //float m = 1.f;
    // float v0 = 1.f;
    //bnu::vector<float> v0(2);
    //v0[0] = 5.f;
    //v0[1] = 1.f;
    //bnu::vector<float> f(2);
    //f[0] = 3.f;
    //f[1] = 4.f;
    //float t = 2.f;
    //bnu::vector<float> vt = f*t/m+v0;
    //bnu::vector<float> va = (vt + v0)/2;
    //bnu::vector<float> s = va * t;
    //bnu::matrix<float> mat(3,3);
    //std::cout<<s[0]<<s[1]<<std::endl;
    system("pause");
}




//#include <boost/gil/extension/io/jpeg_dynamic_io.hpp>
//
//using namespace boost::gil;
//
//template <typename Out>
//struct halfdiff_cast_channels {
//    template <typename T> Out operator()(const T& in1, const T& in2) const {
//        return Out((in2-in1)/2);
//    }
//};
//
//
//template <typename SrcView, typename DstView>
//void x_gradient(const SrcView& src, const DstView& dst) {
//    typedef typename channel_type<DstView>::type dst_channel_t;
//
//    for (int y=0; y<src.height(); ++y) {
//        typename SrcView::x_iterator src_it = src.row_begin(y);
//        typename DstView::x_iterator dst_it = dst.row_begin(y);
//
//        for (int x=1; x<src.width()-1; ++x) {
//            static_transform(src_it[x-1], src_it[x+1], dst_it[x], 
//                halfdiff_cast_channels<dst_channel_t>());
//        }
//    }
//}
//
//template <typename SrcView, typename DstView>
//void x_luminosity_gradient(const SrcView& src, const DstView& dst) {
//    typedef pixel<typename channel_type<SrcView>::type, gray_layout_t> gray_pixel_t;
//    x_gradient(color_converted_view<gray_pixel_t>(src), dst);
//}
//
//int main() {
//    rgb8_image_t img;
//    jpeg_read_image("test.jpg",img);
//
//    gray8s_image_t img_out(img.dimensions());
//    fill_pixels(view(img_out),bits8s(0));
//
//    x_luminosity_gradient(const_view(img), view(img_out));
//    jpeg_write_view("out-x_gradient.jpg",color_converted_view<gray8_pixel_t>(const_view(img_out)));
//
//    return 0;
//}


